package com.explorati.LeetCode538.convertBST;

import javax.swing.text.DateFormatter;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;

/**
 * @ Author : Weijian_Wang
 * @ Date : Created in 22:35 2020/9/21 0021
 * @ Description ：
 */
public class Solution {
      public class TreeNode {
      int val;
      TreeNode left;
      TreeNode right;
      TreeNode(int x) { val = x; }
  }

    int count = 0;
    public TreeNode convertBST(TreeNode root) {
        if(root == null) {
            return null;
        }
        convertBST(root.right);
        count += root.val;
        root.val = count;
        convertBST(root.left);

        return root;
    }

    public static void main(String[] args) {
        String year = "2021";
        String month = "09";
        LocalDate firstDay = LocalDate.of(Integer.parseInt(year), Integer.parseInt(month), 1);
        LocalDate lastDay = firstDay.with(TemporalAdjusters.lastDayOfMonth());
        System.out.println(firstDay.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + " 00:00:00");
        System.out.println(lastDay.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + " 23:59:59");
    }
}
